/**
*
* */
Rsd.define('Rsd.Faith.controls.XiaoQuInput', {
    extend: 'Rsd.control.AutoComplete',
    xtype: 'ctrl-xiaoqu',
    requires: ['Rsd.Faith.stores.XiaoQuStore'],
    margin: '0 0 0 0',
    autoCompleteHandler:'auto_complete',

    /*
    * */
    constructor: function ListMenu(config) {

        this.apply(config);

    },
    auto_complete:function(value,callback)
    {
        var _list = [];
        if(Rsd.isEmpty(value))
        {
            callback(_list);
            return;
        }

        var _store = Rsd.create('Rsd.Faith.stores.XiaoQuStore',{});
        _store.load({},function (data) {

            var list = data.data;
            var str = '';
            for(var i in list)
            {
                str = list[i].MingCheng;
                if(str.indexOf(value)<0)
                {
                    continue;
                }
                else
                {
                    _list.push({id:'b_'+list[i].BianHao,key:list[i].BianHao,text:list[i].MingCheng} );

                }
            }

            callback(_list);
        });

    },
    /*
    * */
    makeControl:function makeControl(config,row) {

        if(Rsd.isEmpty(row))
        {
            return[];
        }
        var _config = config ||{};
        var _editable = _config.editable;
        var _value = row[_config.dataIndex|| _config.dataindex || _config.name];

        var _store = Rsd.create('Rsd.Faith.stores.XiaoQuStore',{});
        _store.load({},function (data) {
        });
        var _ctrl = null;
        if(_editable)
        {
            _ctrl = document.createTextNode('Error:ComboBoxEnum编辑模式未实现');
            return [_ctrl];
        }
        else
        {
            var obj = _store.getObject(_value)||{};
            _ctrl = document.createElement('a');
            _ctrl.href='#';
            _ctrl.innerHTML = obj['MingCheng']||_value;
            $(_ctrl).click (function(){
                Rsd.create('Rsd.Faith.dialogs.InfoXiaoQuWuYeDialog',{data:row['XiaoQuBianHao']}).showDialog();
            });
            return [_ctrl];
        }

    }


},function(type) {

});
